package edu.pitt.cs.cs2410pj2.datamodel;

public class Message {
	private int from; // the node sending the message
	private int to; // the node receiving the message
	private boolean isData = true; // true to be a data message, false to be a control
							// message
	private boolean isSystem = false; // system message will be left out when
										// counting
	// data messages and controlling messages
	private int type; // the type of message
	private int timeOnRoad; // the remaining time the message is on the track
	private String blockAddr; // the block address
	private String data;// data if it is data message, tile ids if control
						// message
	boolean isWaiting = false; // indicates whether the message is waiting for
								// reply, this prevents the message from being
								// counted multiple times
	boolean isUseless = false; //message that are actually meaningless
	
	public void setUseless(boolean useless) {
		isUseless = useless;
		//isSystem = true;
	}
	
	public boolean isUseless() {
		return isUseless;
	}
	
	public String toString() {
		return "FROM:" + from + ",TO:" + to + ",TIME ON ROAD:" + timeOnRoad
				+ ",block address:" + blockAddr+", TYPE:"+MessageType.getTypeName(type)+", DATA:"+data;
	}

	public boolean isWaiting() {
		return isWaiting;
	}

	public void setWaiting(boolean waiting) {
		isWaiting = waiting;
	}

	public void move() {
		timeOnRoad--;
	}

	public int getFrom() {
		return from;
	}

	public void setFrom(int from) {
		this.from = from;
	}

	public int getTo() {
		return to;
	}

	public void setTo(int to) {
		this.to = to;
	}

	public boolean isData() {
		return isData;
	}

	public void setIsData(boolean isData) {
		this.isData = isData;
	}

	public int getTimeOnRoad() {
		return timeOnRoad;
	}

	public void setTimeOnRoad(int timeOnRoad) {
		this.timeOnRoad = timeOnRoad;
	}

	public String getBlockAddr() {
		return blockAddr;
	}

	public void setBlockAddr(String blockAddr) {
		this.blockAddr = blockAddr;
	}

	public boolean isSystem() {
		return isSystem;
	}

	public void setSystem(boolean isSystem) {
		this.isSystem = isSystem;
	}


	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getData() {
		return data;
	}

	public void setData(String data) {
		this.data = data;
	}

}
